package com.maxd.controller.userMoney;

import com.maxd.error.Result;
import com.maxd.error.ResultUtil;
import com.maxd.service.userMoney.UserMoneyDetailsService;
import com.maxd.service.userMoney.UserMoneyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: 房
 * \* Date: 2020/5/15
 * \* Time: 15:46
 * \*
 * \
 */
@RestController
@Api(value = "用户可消费金额", tags = {"用户可消费金额"})
@RequestMapping(value = "/userMoney")
public class UserMoneyController {

    /** 用户金额信息 */
    @Autowired
    private UserMoneyDetailsService UserMoneyDetailsService;
    /** 用户金额明细 */
    @Autowired
    private UserMoneyService UserMoneyService;


    @RequestMapping(value = "/selectUserMoney", method = RequestMethod.GET)
    @ApiOperation("查询用户金额信息")
    @ResponseBody
    public Result selectUserMoney(Long userId)
    {
        return ResultUtil.success(UserMoneyService.selectByUserId(userId));
    }

    @RequestMapping(value = "/selectUserMoneyDetails", method = RequestMethod.GET)
    @ApiOperation("查询用户金额明细信息")
    @ResponseBody
    public Result selectUserMoneyDetails(int page,int size,Long userId)
    {
        Sort.Order order = new Sort.Order(Sort.Direction.DESC, "id");
        Pageable pageable = PageRequest.of(page, size, Sort.by(order));
        return ResultUtil.success(UserMoneyDetailsService.selectUserMoneyDetailsList(userId,pageable));
    }



}